package com.example.jdbc.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @Author ifredomvip@gmail.com
 * @Date 2022/8/2 13:37
 * @Version 1.0.0
 * @Description
 **/
@Component
public class UserDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;


    public List<Map<String, Object>> getAllUser() {
//        return jdbcTemplate.queryForList("select * from user");
        return  null;
    }

    /**
     * 插图一个用户
     */
    @Transactional(rollbackFor = Exception.class)
    public void insetOneUser() {
        String sql = "insert into user values(null,'ifredom','13577770002','1',null,null,1) ";
        jdbcTemplate.execute(sql);

        int x = 10/0;
    }

}
